<?php
/**
 * Created by PhpStrom
 * User: 郭碧云
 * Date: 2021/5/10 10:37
 * Desc:
 */

namespace App\Models\Admin;


use App\Models\BaseModel;

class ModelHasRoles extends BaseModel
{
    protected $table = "model_has_roles";
    public $timestamps = false;

    //更新过期时间
    public function updateExpire($data) {
        $j=0;
        for($i=0;$i<count($data);$i++){
           $reslut = self::where("model_id", $data[$i]["model_id"])->where("role_id",$data[$i]["role_id"])->update(["expire_at"=>$data[$i]["expire_at"]]);
           if(!$reslut){
               $j++;
           }
        }
        return $j>0?false:true;
    }

    //判断是否是站点管理角色
    public function isStieRole($userId){
        return self::where("model_id",$userId)->where("role_id",2)->get();
    }


}
